// 路由配置
import Layout from "../page/Layout";
import Login from "../page/Login/index";
//import CityList from "../page/CityList/cityList";


import { createBrowserRouter } from "react-router-dom";
import React from "react";
import { lazy, Suspense } from "react";


// 1. lazy函数对组件进行导入--路由懒加载
const Home = lazy(() => import('../page/Home/home'))
const HomeList = lazy(() => import('../page/HomeList/index'))
const News = lazy(() => import('../page/News/index'))
const Profile = lazy(() => import('../page/Profile/index'))
const Map = lazy(() => import('../page/Map/map'))

// 配置路由实例
const router = createBrowserRouter([
  {
    path: '/',
    element: <Layout></Layout>,
    children: [
      {
        // 设置默认二级路由
        index: true,
        element: <Home />
      },
      {
        path: '/home/list',
        element: <Suspense fallback={<div>Loading...</div>}><HomeList /></Suspense>
      },
      {
        path: 'news',
        element: <Suspense fallback={<div>Loading...</div>}><News /></Suspense>
      },
      {
        path: 'profile',
        element: <Suspense fallback={<div>Loading...</div>}><Profile /></Suspense>
      },
    ]
  },
  {
    path: '/login',
    element: <Login />
  },
  {
    path: '/map',
    element: <Map />
  },
  // {
  //   path: '*',
  //   element: <NotFound />
  // },

], {
  future: {
    v7_relativeSplatPath: true,
    v7_startTransition: true,
    v7_skipActionErrorRevalidation: true,
    v7_partialHydration: true,
  }
})

export default router